import 'package:casdon/modules/me/data/api/browsing_life_history_api.dart';

class BrowsingLifeHistoryModel {
  final String title;
  final String? mainImg;
  final String author;
  final String createTime;
  final String id;

  BrowsingLifeHistoryModel({
    required this.title,
    required this.mainImg,
    required this.author,
    required this.createTime,
    required this.id,
  });

  // 静态方法转换
  static BrowsingLifeHistoryModel fromApi(TopicHistory response) {
    return BrowsingLifeHistoryModel(
      title: response.title ?? '',
      mainImg: response.mainImg ,
      author: response.nickName ?? "匿名用户",
      createTime: response.createTime ?? "",
      id: response.id,
    );
  }

  // 批量转换的静态方法
  static List<BrowsingLifeHistoryModel> listFromApi(List<TopicHistory> items) {
    return items.map(fromApi).toList();
  }
}
